import com.wf.captcha.utils.CaptchaUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "yanzheng", value = "/yanzheng")
public class yanzheng extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;setchar=UTF-8");
        String s = request.getParameter("yanzhengma");
        PrintWriter out = response.getWriter();
        if (s == null || "".equals(s)) {
            out.print("<p>验证码为空！</p>");
        } else if (CaptchaUtil.ver(s, request)) {
            out.print("登录成功");
        } else {
            out.print("验证码错误");
        }
    }
}
